package com.bwie.controller;
import com.bwie.pojo.TbProd;
import com.bwie.pojo.TbProdAtta;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.ProdInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
 * @author LiuWei Chen
 * @version 1.0
 * @description: TODO
 * @date 2025/7/22 19:50
 */
@RestController
@RequestMapping("/prod/index")
public class ProductController {
    @Autowired
    TbProdService prodService;

    /**
     * @return com.bwie.utils.R
     * @author LiuWeiChen
     * @description 获取商品列表
     * @params [pageInfoVo]
     * @date 2025/07/23 10:35
     */
    @PostMapping("/getPageListProd")
    public R getPageListProd(@RequestBody PageInfoVo pageInfoVo) {
        return prodService.getPageListProd(pageInfoVo);
    }

    @PostMapping("/addProd")
    public R addProd(@RequestBody TbProd tbProd) {
        return prodService.addProd(tbProd);
    }

    @PostMapping("/addProdAtta")
    public R addProdAtta(@RequestBody TbProdAtta tbProdAtta) {
        return prodService.addProdAtta(tbProdAtta);
    }

    @PostMapping("/uploadFile")
    public R uploadFile(@RequestPart("file") MultipartFile file) {
        return prodService.uploadFile(file);
    }

    @PostMapping("/deleteBatchProd")
    public R deleteBatchProd(@RequestBody List<Integer> ids) {
        return prodService.deleteBatchProd(ids);
    }

    @PostMapping("/deleteProd/{prodId}")
    public R deleteProd(@PathVariable("prodId") Integer prodId) {
        return prodService.deleteProd(prodId);
    }

    /**
     * @return com.bwie.utils.R
     * @description 根据商品ID获取商品信息
     * @params [prodId]
     * @author 军哥
     * @date 2025/7/24 15:31
     */
    @PostMapping("/getProdById/{prodId}")
    public R getProdById(@PathVariable("prodId") Integer prodId) {
        return prodService.getProdById(prodId);
    }

    /**
     * @return com.bwie.utils.R
     * @description 根据商品ID获取商品SKU信息
     * @params [prodInfoVo]
     * @author 军哥
     * @date 2025/7/24 16:02
     */
    @PostMapping("/getProdInfoList")
    public R getProdInfoList(@RequestBody ProdInfoVo prodInfoVo) {
        return prodService.getProdInfoList(prodInfoVo);
    }

    /**
     * @return com.bwie.utils.R
     * @description 添加商品明细
     * @params [tbProdInfo]
     * @author 军哥
     * @date 2025/7/24 16:24
     */
    @PostMapping("/addProdInfo")
    public R addProdInfo(@RequestBody TbProdInfo tbProdInfo) {
        return prodService.addProdInfo(tbProdInfo);
    }
    /**
     * @author LiuWeiChen
     * @description selectProdInfoByProdId
     * @params [prodId, pageInfoVo]
     * @return com.bwie.utils.R
     * @date 2025/7/28 09:50
    */
    @PostMapping("/selectProdInfo")
    public R selectProdInfo() {
        return prodService.selectProdInfo();
    }
}